<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="base" uri="http://qdbp.gitee.io/tags/base/"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>

<link href="<base:url href='assets/${pv.view}.css'/>" rel="stylesheet" type="text/css" />

<table class="x-datagrid main-datalist"
		data-options="toolbar:'.toolbar-box',
		method:'POST',url:'<base:url href='actions/role/list.json'/>',
		fixedParams:{
			<shiro:lacksPermission name="root:develop">userType:'ADMIN',defaults:false,</shiro:lacksPermission>
			fillResources:true,ordering:'sortIndex asc, createTime desc'},
		xextra:[{RoleResources:onFilterExtraResources}]">
	<thead>
		<tr>
			<th data-options="field:'id',width:100,align:'center',checkbox:true">选择</th>
			<th data-options="field:'roleName',width:200,align:'center',xpopup:'update'">角色名称</th>
			<shiro:hasPermission name="root:develop">
			<th data-options="field:'userType',width:100,align:'center',xextra:'UserType'">用户类型</th>
			<th data-options="field:'defaults',width:50,align:'center',xextra:'Boolean'">默认</th>
			</shiro:hasPermission>
			<th data-options="field:'roleDesc',width:450,align:'center'">角色描述</th>
			<th data-options="field:'creatorName',width:80,align:'center'">创建人</th>
			<th data-options="field:'createTime',width:150,align:'center'">创建时间</th>
		</tr>
	</thead>
</table>


<div class="hide">
	<%--
	<div class="x-dialog container-fluid" title="测试" 
			data-options="xpopup:'complex',width:1000,height:'90%',modal:true,iconCls:'fa fa-plus',
			onAfterFillData:onDistributeAfterFillData,onAfterOpen:onDistributeAfterOpen">
		<div class="x-layout" data-options="fit:true,border:false">
			<div data-options="region:'north',split:false,border:false" style="height:140px;">
				<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/role/create.json'/>">
					<dd>
						<input type="hidden" name="id" />
						<div class="spacer-right">
							<div class="form-group">
								<div class="col-md-2 control-label"><i class="asterisk"></i>角色名称</div>
								<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="roleName" data-options="required:true,validType:['illegalChar','length[0,30]']"/></div>
								<div class="col-md-1 control-label">排序</div>
								<div class="col-md-4 control-input"><input class="x-numberbox" type="text" name="sortIndex" data-options="min:0,validType:'length[0,8]'"/></div>
							</div>
							<div class="form-group mb-clear">
								<div class="col-md-2 control-label">角色描述</div>
								<div class="col-md-10 control-input"><input class="x-textbox" type="text" name="roleDesc" data-options="multiline:true,height:50,validType:['illegalChar','length[0,200]']"/></div>
							</div>
						</div>
					</dd>
				</form>
			</div>
			<div class="border-top-dark" data-options="region:'center',split:false,border:false">
				<table class="x-treegrid authority"
					data-options="fit:true,border:false,
					method:'POST',url:'<base:url href="actions/role/resource/list.json"/>',
					fixedParams:{ordering:'sortIndex asc, createTime desc'},
					idField:'id',parentField:'parentId',treeField:'name', loadFilter:onResourceLoadFilter,
					xextra:{fields:[{field:'Resource',key:'id',value:'name',parent:'parentId'}],map:{Resource:'body'}}, 
					iconCls:'tree-checkbox'">
					<thead>
						<tr>
							<th data-options="field:'name',width:200,align:'left'"><span class="check-label">全部</span></th>
							<th data-options="field:'operates',width:750,align:'left',halign:'center',formatter:format.operatesToText">操作权限</th>
						</tr>
					</thead>
				</table>
			</div>
		</div>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save',closeOnSuccess:false,message:'保存',onSuccess:onCreateContinue">保存并继续</a>
			<shiro:hasPermission name="permission:role:update">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	--%>
	<div class="x-dialog container-fluid" title="新增角色" data-options="xpopup:'create',width:500,modal:true,iconCls:'fa fa-plus'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/role/create.json'/>">
			<dd>
				<shiro:lacksPermission name="root:develop">
					<input type="hidden" name="userType" value="ADMIN" data-clear="false" />
				</shiro:lacksPermission>
				<div class="spacer-right">
					<div class="form-group">
						<div class="col-md-3 control-label"><i class="asterisk"></i>角色名称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="roleName" data-options="required:true,validType:['illegalChar','length[0,30]']"/></div>
					</div>
					<shiro:hasPermission name="root:develop">
					<div class="form-group">
						<div class="col-md-3 control-label">用户类型</div>
						<div class="col-md-9 control-input"><input class="x-combobox" type="text" name="userType" data-def-value="ADMIN" data-options="editable:false,required:true,xextra:{field:'UserType',ignore:['SYSTEM']}"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">默认角色</div>
						<div class="col-md-9 control-input"><input class="x-combobox" type="text" name="defaults" data-def-value="false" data-options="editable:false,required:true,xextra:'Boolean'"/></div>
					</div>
					</shiro:hasPermission>
					<div class="form-group">
						<div class="col-md-3 control-label">排序</div>
						<div class="col-md-9 control-input"><input class="x-numberbox" type="text" name="sortIndex" data-options="min:0,validType:'length[0,8]'"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">角色描述</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="roleDesc" data-options="multiline:true,height:50,validType:['illegalChar','length[0,200]']"/></div>
					</div>
				</div>
			</dd>
		</form>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save',closeOnSuccess:false,message:'保存',onSuccess:onCreateContinue">保存并继续</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog container-fluid" title="角色信息" data-options="xpopup:'update',width:500,modal:true,iconCls:'fa fa-pencil'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/role/update.json'/>">
			<dd>
				<input type="hidden" name="id" />
				<div class="spacer-right">
					<div class="form-group">
						<div class="col-md-3 control-label"><i class="asterisk"></i>角色名称</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="roleName" data-options="required:true,validType:['illegalChar','length[0,30]']"/></div>
					</div>
					<shiro:hasPermission name="root:develop">
					<div class="form-group">
						<div class="col-md-3 control-label">用户类型</div>
						<div class="col-md-9 control-input"><input class="x-combobox" type="text" name="userType" data-options="editable:false,required:true,xextra:{field:'UserType',ignore:['SYSTEM']}"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">默认角色</div>
						<div class="col-md-9 control-input"><input class="x-combobox" type="text" name="defaults" data-def-value="false" data-options="editable:false,required:true,xextra:'Boolean'"/></div>
					</div>
					</shiro:hasPermission>
					<div class="form-group">
						<div class="col-md-3 control-label">排序</div>
						<div class="col-md-9 control-input"><input class="x-numberbox" type="text" name="sortIndex" data-options="min:0,validType:'length[0,8]'"/></div>
					</div>
					<div class="form-group">
						<div class="col-md-3 control-label">角色描述</div>
						<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="roleDesc" data-options="multiline:true,height:50,validType:['illegalChar','length[0,200]']"/></div>
					</div>
				</div>
			</dd>
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="permission:role:update">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog container-fluid" title="权限分配" data-options="xpopup:'distribute',width:1200,height:'90%',modal:true,iconCls:'fa fa-link'">
		<table class="x-treegrid distribute"
			data-options="fit:true,border:false,
			method:'POST',url:'<base:url href="actions/role/resource/list.json"/>',
			fixedParams:{sceneType:'manager',state:'NORMAL',ordering:'sortIndex asc, createTime desc'},
			idField:'id',parentField:'parentId',treeField:'name', loadFilter:onResourceLoadFilter,
			xextra:{fields:[{field:'Resource',key:'id',value:'name',parent:'parentId'}],map:{Resource:'body'}}, 
			iconCls:'tree-checkbox'">
			<thead>
				<tr>
					<th data-options="field:'name',width:200,align:'left'"><span class="check-label">全部</span></th>
					<th data-options="field:'operates',width:950,align:'left',halign:'center',formatter:format.operatesToText">操作权限</th>
				</tr>
			</thead>
		</table>
		<form class="hide" method="POST" action="<base:url href='actions/role/distribute.json'/>">
			<input type="hidden" name="id" />
			<input type="hidden" name="sceneType" value="manager" data-clear="false" />
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="permission:role:distribute">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save',onBefore:onDistributeBeforeSubmit">分配</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="x-dialog container-fluid" title="删除" data-options="xpopup:'delete',width:320,modal:true,iconCls:'fa fa-minus'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/role/delete.json'/>">
			<dd>
				<span>确定要删除<abbr title="勾选指的是在第一列打勾，可以同时选中多行记录">勾选</abbr>的 <span class="records"></span> 条记录?</span>
			</dd>
		</form>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-check',message:'删除'">确定</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>
	<div class="toolbar-box">
		<form>
			<div class="toolbar-item">
				<span class="toolbar-text">角色名称:</span><input name="roleNameLike" class="x-textbox panel-input"/>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'search',iconCls:'fa fa-search'">查询</a>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'reset'<%--,iconCls:'fa fa-circle-thin'--%>">重置</a>
				<div class="clear"></div>
			</div>
			<div class="toolbar-item">
				<%-- <a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'details',selection:'single',iconCls:'fa fa-file-text-o'">详情</a> --%>
				<%-- <a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'complex',iconCls:'fa fa-plus',fillData:false">测试</a> --%>
				<shiro:hasPermission name="permission:role:create">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'create',iconCls:'fa fa-plus',fillData:false">创建</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="permission:role:update">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'update',selection:'single',iconCls:'fa fa-pencil'">修改</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="permission:role:delete">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'delete',selection:'multi',iconCls:'fa fa-minus',fillData:false,fillData:{id:'ids',i:'.records'}">删除</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="permission:role:distribute">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'distribute',selection:'single',iconCls:'fa fa-link',onAfterFillData:onDistributeAfterFillData,onAfterOpen:onDistributeAfterOpen">权限分配</a>
				</shiro:hasPermission>
				<shiro:lacksPermission name="permission:role:distribute">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'distribute',selection:'single',iconCls:'fa fa-link',dataReadonly:true,onAfterFillData:onDistributeAfterFillData,onAfterOpen:onDistributeAfterOpen">权限详情</a>
				</shiro:lacksPermission>
				<%--
				<shiro:hasPermission name="permission:role:import">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'import',iconCls:'fa fa-sign-in'">导入</a>
				</shiro:hasPermission>
				<shiro:hasPermission name="permission:role:export">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'export',iconCls:'fa fa-sign-out'">导出</a>
				</shiro:hasPermission>
				--%>
			</div>
			<div class="clear"></div>
		</form>
	</div>
</div>

<script src="<base:url href='assets/${pv.view}.js'/>"></script>
